package com.example.inami.third.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.inami.common.domain.R;
import com.example.inami.common.web.BaseController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.inami.third.entity.NbIotYunSyncInfo;
import com.example.inami.third.service.NbIotYunSyncInfoService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * 同步记录(NbIotYunSyncInfo)表控制层
 *
 * @author inami
 * @since 2025-03-03 09:30:29
 */
@RestController
@RequestMapping("nbIotYunSyncInfo")
public class NbIotYunSyncInfoController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private NbIotYunSyncInfoService nbIotYunSyncInfoService;

    /**
     * 分页查询所有数据
     *
     * @param page             分页对象
     * @param nbIotYunSyncInfo 查询实体
     * @return 所有数据
     */
    @RequestMapping("list")
    public R selectAll(Page<NbIotYunSyncInfo> page, NbIotYunSyncInfo nbIotYunSyncInfo) {
        return R.ok(this.nbIotYunSyncInfoService.page(page, new QueryWrapper<>(nbIotYunSyncInfo)));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @RequestMapping("{id}")
    public R selectOne(@PathVariable Serializable id) {
        return R.ok(this.nbIotYunSyncInfoService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param nbIotYunSyncInfo 实体对象
     * @return 新增结果
     */
    @RequestMapping("save")
    public R insert(@RequestBody @Validated NbIotYunSyncInfo nbIotYunSyncInfo) {
        return R.ok(this.nbIotYunSyncInfoService.save(nbIotYunSyncInfo));
    }

    /**
     * 修改数据
     *
     * @param nbIotYunSyncInfo 实体对象
     * @return 修改结果
     */
    @RequestMapping("update")
    public R update(@RequestBody NbIotYunSyncInfo nbIotYunSyncInfo) {
        return R.ok(this.nbIotYunSyncInfoService.updateById(nbIotYunSyncInfo));
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @RequestMapping("delete")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return R.ok(this.nbIotYunSyncInfoService.removeByIds(idList));
    }
}

